<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      ref="crud"
      :page.sync="page"
      :search.sync="search"
      v-model="form"
      @row-del="rowDel"
      @row-update="rowUpdate"
      @row-save="rowSave"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
      @tree-load="treeLoad"
    >
      <template slot="menuLeft">
        <el-button type="primary" size="small" icon="el-icon-plus" v-if="permission.productpackingconfig_add_refactor" @click="handleAdd">新 增</el-button>
        <el-button type="danger" size="small" icon="el-icon-delete" v-if="permission.productpackingconfig_delete_refactor" @click="handleDelete">删 除 </el-button>
      </template>
      <template slot-scope="scope" slot="menu">
        <el-button icon="el-icon-view" size="small" type="text" v-if="permission.productpackingconfig_view_refactor" @click="opendetailRow(scope.row, 'view')">详情</el-button>
        <el-button icon="el-icon-edit" size="small" type="text" v-if="permission.productpackingconfig_edit_refactor" @click.stop="opendetailRow(scope.row, 'edit')"
          >编辑</el-button
        >
        <el-button icon="el-icon-delete" size="small" type="text" v-if="permission.productpackingconfig_delete_refactor" @click.stop="detailRowDel(scope.row, scope.index, done)"
          >删除
        </el-button>
        <el-button type="text" icon="el-icon-circle-plus-outline" size="small" v-if="permission.productpackingconfig_addChild_refactor" @click.stop="handleAddChild(scope.row)"
          >新增子项
        </el-button>
      </template>
      <template slot-scope="{ row }" slot="source">
        <div style="text-align: center">
          <i :class="row.source" />
        </div>
      </template>
      <template slot-scope="{ row }" slot="clientType">
        <el-tag>{{ row.clientType }}</el-tag>
      </template>
    </avue-crud>
    <el-dialog class="showDialog" ref="dialog" :title="dialogTitle" append-to-body :visible.sync="showDialog" top="5vh" @close="closeDialog">
      <avue-form v-if="showDialog" ref="form" v-model="form" :option="basicDataOption"></avue-form>
      <span slot="footer" class="dialog-footer">
        <el-button v-if="dialogTitle === '新增' || dialogTitle === '新增子项'" size="small" type="primary" @click="submit">
          <i class="el-icon-circle-plus-outline"></i><span>保 存</span></el-button
        >
        <el-button v-if="dialogTitle === '编辑'" size="small" type="primary" @click="submit"> <i class="el-icon-circle-check"></i><span>修 改</span></el-button>
        <el-button size="small" @click="showDialog = false"><i class="el-icon-circle-close"></i><span>取 消</span></el-button>
      </span>
    </el-dialog>
    <common-modal-template ref="commonModalTemplate" :option="tableOption" @getSelectedRows="getSelectedRows" :key="timer" @newKey="newKey"></common-modal-template>
  </basic-container>
</template>

<script>
import { getList, remove, add, getChild, getDetail } from '@/api/product/productpackingconfig';
import { mapGetters } from 'vuex';
import CommonModalTemplate from '@/components/common-modal-template/common-modal-template.vue';

export default {
  name: 'ProductProductpackingconfig',
  components: {
    CommonModalTemplate
  },
  data() {
    return {
      form: {},
      query: {},
      loading: true,
      selectionList: [],
      page: {
        pageSize: 20,
        currentPage: 1,
        total: 0
      },
      option: {
        height: 'calc(100vh - 360px)',
        calcHeight: 30,
        lazy: true,
        tip: false,
        simplePage: true,
        searchShow: true,
        searchMenuSpan: 6,
        dialogWidth: '60%',
        border: true,
        index: true,
        indexLabel: '序号',
        selection: true,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        viewBtn: false,
        viewBtnText: '详情',
        viewText: '详情',
        menuWidth: 300,
        dialogClickModal: false,
        columnBtn: false,
        rowKey: 'id',
        column: [
          {
            label: '包装名称',
            prop: 'name'
          },
          {
            label: '产品编码',
            prop: 'productPartNo',
            search: true,
            searchType: 'search',
            appendClick: () => {
              this.openPartNoCommonModal('searchPartNoModal');
            }
          },
          {
            label: '产品名称',
            prop: 'productPartName'
          },
          {
            label: '产品型号',
            prop: 'productPartModel'
          },
          {
            label: '产品规格',
            prop: 'productPartSpec'
          },
          {
            label: '物料类别',
            prop: 'partCategoryName'
          },
          {
            label: '包规数量',
            prop: 'packingSpecQty'
          }
        ]
      },
      data: [],
      dialogTitle: '新增',
      basicDataOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 150,
        group: [
          {
            label: '产品信息',
            prop: 'partInfo',
            arrow: false,
            icon: 'el-icon-vertical-bar',
            display: true,
            column: [
              {
                label: '产品编码',
                prop: 'productPartNo',
                type: 'search',
                disabled: true,
                rules: [
                  {
                    required: true,
                    message: '请选择产品编码',
                    trigger: 'blur'
                  }
                ],
                appendClick: () => {
                  if (this.dialogTitle === '新增') {
                    this.openPartNoCommonModal('partNoModal');
                  }
                }
              },
              {
                label: '产品名称',
                prop: 'productPartName',
                disabled: true
              }
            ]
          },
          {
            label: '包规信息',
            prop: 'packingInfo',
            arrow: false,
            icon: 'el-icon-vertical-bar',
            column: [
              {
                label: '包装名称',
                prop: 'name',
                rules: [
                  {
                    required: true,
                    message: '请输入包装名称',
                    trigger: 'blur'
                  }
                ]
              },
              {
                label: '包规数量',
                prop: 'packingSpecQty',
                type: 'number',
                value: undefined,
                rules: [
                  {
                    required: true,
                    trigger: 'blur',
                    validator: (rule, value, callback) => {
                      let reg = /^[1-9]\d*$/g;
                      if (value && !reg.test(value)) {
                        callback(new Error('包规数量不能小于0并且是整数'));
                      } else if (!value) {
                        callback(new Error('包规数量不能为空'));
                      } else {
                        callback();
                      }
                    }
                  }
                ]
              },
              {
                label: '是否周转箱',
                prop: 'isCarrier',
                type: 'switch',
                labelTip: '若为周转箱，不会对包规数量进行校验管控',
                value: false,
                dicData: [
                  {
                    label: '否',
                    value: false
                  },
                  {
                    label: '是',
                    value: true
                  }
                ]
              }
            ]
          },
          {
            label: '标签信息',
            prop: 'labelInfo',
            arrow: false,
            icon: 'el-icon-vertical-bar',
            column: [
              {
                label: '包装标签模版',
                prop: 'templateName',
                type: 'search',
                disabled: true,
                rules: [
                  {
                    required: true,
                    message: '请选择包装标签模版',
                    trigger: 'blur'
                  }
                ],
                appendClick: () => {
                  this.openLabelTemplateCommonModal();
                }
              },
              {
                label: '包装序列号规则',
                prop: 'sequenceDefinitionName',
                type: 'search',
                disabled: true,
                rules: [
                  {
                    required: true,
                    message: '请选择包装序列号规则',
                    trigger: 'blur'
                  }
                ],
                appendClick: () => {
                  this.openSequenceDefinitionCommonModal();
                }
              }
            ]
          },
          {
            label: '重量信息',
            prop: 'weightInfo',
            arrow: false,
            icon: 'el-icon-vertical-bar',
            column: [
              {
                label: '标准重量（装箱时）',
                prop: 'boxingStandardWeight',
                type: 'number',
                value: undefined,
                change: (val) => {
                  if (val.value === null || (val.value != 0 && !val.value)) {
                    this.form.boxingStandardWeight = undefined;
                  } else {
                    if (this.form.weightTolerance === 1 && val.value) {
                      this.form.sealingMaxWeight = this.form.boxingForward ? this.weightCount(val.value, this.form.boxingForward, '+') : '';
                      this.form.sealingMinWeight = this.form.sealingNegative ? this.weightCount(val.value, this.form.sealingNegative, '-') : '';
                    }
                    if (this.form.weightTolerance === 2 && val.value) {
                      if (this.form.boxingForward) {
                        let num1 = Number(val.value) * (Number(this.form.boxingForward) / 100);
                        this.form.sealingMaxWeight = this.weightCount(val.value, num1, '+');
                      }
                      if (this.form.sealingNegative) {
                        let num2 = Number(val.value) * (Number(this.form.sealingNegative) / 100);
                        this.form.sealingMinWeight = this.weightCount(val.value, num2, '-');
                      }
                    }
                  }
                }
              },
              {
                label: '标准重量（封箱时）',
                prop: 'sealingStandardWeight',
                type: 'number',
                value: undefined,
                change: (val) => {
                  if (val.value === null || (val.value != 0 && !val.value)) {
                    this.form.sealingStandardWeight = undefined;
                  } else {
                    if (this.form.weightTolerance === 1 && val.value) {
                      this.form.boxingMaxWeight = this.form.sealingForward ? this.weightCount(val.value, this.form.sealingForward, '+') : '';
                      this.form.boxingMinWeight = this.form.boxingNegative ? this.weightCount(val.value, this.form.boxingNegative, '-') : '';
                    }
                    if (this.form.weightTolerance === 2 && val.value) {
                      if (this.form.sealingForward) {
                        let num1 = Number(val.value) * (Number(this.form.sealingForward) / 100);
                        this.form.boxingMaxWeight = this.weightCount(val.value, num1, '+');
                      }
                      if (this.form.boxingNegative) {
                        let num2 = Number(val.value) * (Number(this.form.boxingNegative) / 100);
                        this.form.boxingMinWeight = this.weightCount(val.value, num2, '-');
                      }
                    }
                  }
                }
              },
              {
                label: '重量单位',
                prop: 'uom',
                type: 'select',
                dicData: [
                  {
                    label: 'kg',
                    value: 'kg'
                  },
                  {
                    label: 'g',
                    value: 'g'
                  }
                ]
              },
              {
                label: '重量公差',
                prop: 'weightTolerance',
                type: 'radio',
                span: 24,
                labelTip: '选中绝对值，下方输入框输入正数；选中相对值，下方输入框后显示"%"符号，详情见页面交互',
                disabled: this.readOnlyPage,
                dicData: [
                  {
                    label: '绝对值',
                    value: 1
                  },
                  {
                    label: '相对值',
                    value: 2
                  }
                ],
                value: 1,
                change: (val) => {
                  const weightInfo = this.findNode(this.basicDataOption.group, 'weightInfo');
                  const boxingForward = this.findNode(weightInfo.column, 'boxingForward');
                  const sealingNegative = this.findNode(weightInfo.column, 'sealingNegative');
                  const sealingForward = this.findNode(weightInfo.column, 'sealingForward');
                  const boxingNegative = this.findNode(weightInfo.column, 'boxingNegative');
                  if (val.value === 1) {
                    boxingForward.label = '装箱时：正向（+）';
                    sealingNegative.label = '装箱时：负向（-）';
                    sealingForward.label = '封箱时：正向（+）';
                    boxingNegative.label = '封箱时：负向（-）';
                  } else {
                    boxingForward.label = '装箱时：正向（+）%';
                    sealingNegative.label = '装箱时：负向（-）%';
                    sealingForward.label = '封箱时：正向（+）%';
                    boxingNegative.label = '封箱时：负向（-）%';
                  }
                },
                click: (val) => {
                  this.form.boxingForward = undefined;
                  this.form.sealingNegative = undefined;
                  this.form.sealingForward = undefined;
                  this.form.boxingNegative = undefined;
                  this.form.sealingMaxWeight = '';
                  this.form.sealingMinWeight = '';
                  this.form.boxingMaxWeight = '';
                  this.form.boxingMinWeight = '';
                }
              },
              {
                label: '装箱时：正向（+）',
                prop: 'boxingForward',
                type: 'number',
                value: undefined,
                change: (val) => {
                  console.log(val.value);
                  if (val.value === null || (val.value != 0 && !val.value)) {
                    this.form.boxingForward = undefined;
                    this.form.sealingMaxWeight = '';
                  } else {
                    if (this.form.weightTolerance === 1 && this.form.boxingStandardWeight) {
                      this.form.sealingMaxWeight = this.weightCount(this.form.boxingStandardWeight, val.value, '+');
                    }
                    if (this.form.weightTolerance === 2 && this.form.boxingStandardWeight) {
                      let num = Number(this.form.boxingStandardWeight) * (Number(val.value) / 100);
                      this.form.sealingMaxWeight = this.weightCount(this.form.boxingStandardWeight, num, '+');
                    }
                  }
                }
              },
              {
                label: '装箱时：负向（-）',
                prop: 'sealingNegative',
                type: 'number',
                value: undefined,
                change: (val) => {
                  if (val.value === null || (val.value != 0 && !val.value)) {
                    this.form.sealingNegative = undefined;
                    this.form.sealingMinWeight = '';
                  } else {
                    if (this.form.weightTolerance === 1 && this.form.boxingStandardWeight) {
                      this.form.sealingMinWeight = this.weightCount(this.form.boxingStandardWeight, val.value, '-');
                    }
                    if (this.form.weightTolerance === 2 && this.form.boxingStandardWeight) {
                      let num = Number(this.form.boxingStandardWeight) * (Number(val.value) / 100);
                      this.form.sealingMinWeight = this.weightCount(this.form.boxingStandardWeight, num, '-');
                    }
                  }
                }
              },
              {
                label: '封箱时：正向（+）',
                prop: 'sealingForward',
                type: 'number',
                value: undefined,
                change: (val) => {
                  if (val.value === null || (val.value != 0 && !val.value)) {
                    this.form.sealingForward = undefined;
                    this.form.boxingMaxWeight = '';
                  } else {
                    if (this.form.weightTolerance === 1 && this.form.sealingStandardWeight) {
                      this.form.boxingMaxWeight = this.weightCount(this.form.sealingStandardWeight, val.value, '+');
                    }
                    if (this.form.weightTolerance === 2 && this.form.sealingStandardWeight) {
                      let num = Number(this.form.sealingStandardWeight) * (Number(val.value) / 100);
                      this.form.boxingMaxWeight = this.weightCount(this.form.sealingStandardWeight, num, '+');
                    }
                  }
                }
              },
              {
                label: '封箱时：负向（-）',
                prop: 'boxingNegative',
                type: 'number',
                value: undefined,
                change: (val) => {
                  if (val.value === null || (val.value != 0 && !val.value)) {
                    this.form.boxingNegative = undefined;
                    this.form.boxingMinWeight = '';
                  } else {
                    if (this.form.weightTolerance === 1 && this.form.sealingStandardWeight) {
                      this.form.boxingMinWeight = this.weightCount(this.form.sealingStandardWeight, val.value, '-');
                    }
                    if (this.form.weightTolerance === 2 && this.form.sealingStandardWeight) {
                      let num = Number(this.form.sealingStandardWeight) * (Number(val.value) / 100);
                      this.form.boxingMinWeight = this.weightCount(this.form.sealingStandardWeight, num, '-');
                    }
                  }
                }
              },
              {
                label: '重量上限（装箱时）',
                prop: 'sealingMaxWeight',
                disabled: true
              },
              {
                label: '重量下限（装箱时）',
                prop: 'sealingMinWeight',
                disabled: true
              },
              {
                label: '重量上限（封箱时）',
                prop: 'boxingMaxWeight',
                disabled: true
              },
              {
                label: '重量下限（封箱时）',
                prop: 'boxingMinWeight',
                disabled: true
              }
            ]
          }
        ]
      },
      showDialog: false,
      tableOption: {},
      timer: new Date().getTime(),
      search: {}
    };
  },
  computed: {
    ...mapGetters(['userInfo', 'permission']),
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids;
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.$structuralSplit();
    });
  },
  methods: {
    findNode(list = [], prop) {
      let node;
      list.forEach((ele) => {
        if (ele.prop === prop) node = ele;
      });
      return node;
    },
    handleAdd() {
      this.showDialog = true;
      this.dialogTitle = '新增';
      this.basicDataOption.group[0].display = true;
      this.form.parentId = '';
      this.form.weightTolerance = 1;
      this.form.level = 1;
      this.$nextTick(() => {
        this.$refs.form.allDisabled = false;
      });
    },
    handleAddChild(row) {
      if (row.hasChild) {
        this.$message({
          type: 'warning',
          message: '当前行已存在子项！'
        });
        return;
      }
      this.dialogTitle = '新增子项';
      this.basicDataOption.group[0].display = false;
      this.showDialog = true;
      this.form.parentId = row.id;
      this.form.weightTolerance = 1;
      this.form.level = Number(row.level) + 1;
      this.$nextTick(() => {
        this.$refs.form.allDisabled = false;
      });
    },
    closeDialog() {
      this.$refs.form.resetFields();
      this.form = {};
      console.log(this.form);
    },
    openPartNoCommonModal(name) {
      this.modalName = name;
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择产品信息（双击进行选择）',
        url: '/api/mes-admin/part-master/page?semifinished=true',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '类型',
            prop: 'categoryId',
            search: true,
            type: 'tree',
            dicUrl: '/api/mes-admin/part-category/tree',
            props: {
              label: 'title',
              value: 'id'
            }
          },
          {
            label: '编码',
            prop: 'partNo',
            search: true
          },
          {
            label: '名称',
            prop: 'name',
            search: true
          },
          {
            label: '型号',
            prop: 'partModel'
          },
          {
            label: '描述',
            prop: 'description'
          },
          {
            label: '版本',
            prop: 'revision'
          }
        ]
      };
    },
    /**
     * 打开标签模版选择模态框
     */
    openLabelTemplateCommonModal() {
      this.modalName = 'labelTemplateModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择标签模版（双击进行选择）',
        url: '/api/mes-admin/labeltemplate/page?type=MATERIAL&subType=FINISHED_PRODUCT_PACKAGING&isLastest=true',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '标签名称',
            prop: 'fileName',
            search: true
          },
          {
            label: '标签代码',
            prop: 'code',
            search: true
          },
          {
            label: '版本名称',
            prop: 'revision'
          },
          {
            label: '缩略图',
            prop: 'thumbnailUrl',
            type: 'upload',
            loadText: '缩略图上传中，请稍等',
            propsHttp: {
              url: 'link',
              name: 'originalName',
              res: 'data'
            }
          },
          {
            label: '打印标签',
            prop: 'fileUrl'
          }
        ]
      };
    },
    /**
     * 打开序列号规则选择模态框
     */
    openSequenceDefinitionCommonModal() {
      this.modalName = 'serialNumberModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择成品包装条码（双击进行选择）',
        url: '/api/mes-admin/sequencedefinition/page?subType=FINISHED_PRODUCT_PACKAGING&type=material',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '规则名称',
            prop: 'name',
            search: true
          },
          {
            label: '规则编码',
            prop: 'code',
            search: true
          },
          {
            label: '序列号规则',
            prop: 'sequenceNoFormat',
            labelslot: true,
            rules: [
              {
                required: true,
                message: '请输入序列号规则',
                trigger: 'blur'
              }
            ]
          }
        ]
      };
    },
    /**
     * 选择模态框行数据
     */
    getSelectedRows(rowData) {
      switch (this.modalName) {
        case 'partNoModal':
          this.form.productPartNo = rowData.partNo;
          this.form.productPartId = rowData.id;
          this.form.productPartName = rowData.name;
          break;
        case 'searchPartNoModal':
          this.search.productPartNo = rowData.partNo;
          break;
        case 'labelTemplateModal':
          this.form.labelTemplateId = rowData.id;
          this.form.templateName = rowData.fileName;
          break;
        case 'serialNumberModal':
          this.form.sequenceDefinitionId = rowData.id;
          this.form.sequenceDefinitionName = rowData.name;
          break;
        default:
          break;
      }
    },
    submit() {
      this.$refs.form.validate((valid, done) => {
        if (valid) {
          add(this.form).then(
            (res) => {
              // 获取新增数据的相关字段
              // const data = res.data.data;
              // row.id = data.id;
              this.showDialog = false;
              this.$message({
                type: 'success',
                message: '操作成功!'
              });
              this.onLoad(this.page);
              this.$refs.crud.refreshTable();
              // 数据回调进行刷新
              // done(row);
            },
            (error) => {
              done();
            }
          );
        }
      });
    },
    rowDel(row, index, done) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          return remove([row.id]);
        })
        .then(() => {
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
          // 数据回调进行刷新
          done(row);
        });
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning('请选择至少一条数据');
        return;
      }
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          // 刷新表格数据并重载
          this.data = [];
          this.$refs.crud.refreshTable();
          this.$refs.crud.toggleSelection();
          // 表格数据重载
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
        });
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      params['parentId'] = 0;
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records.map((item) => {
          return {
            ...item,
            hasChildren: item.isHasSubPack
          };
        });
        this.loading = false;
        this.selectionClear();
      });
    },
    treeLoad(tree, treeNode, resolve) {
      getChild({ parentId: tree.id }).then((res) => {
        const data = res.data.data;
        if (Array.isArray(data)) {
          data.forEach((item) => {
            if (item.isHasSubPack) {
              item.hasChildren = true;
            }
          });
        }
        resolve(res.data.data || []);
      });
    },
    /**
     * 重新加载公用表格弹窗组件
     */
    newKey() {
      this.timer = new Date().getTime();
    },
    /**
     * 打开编辑模态框
     */
    opendetailRow(row, type) {
      this.showDialog = true;
      this.dialogTitle = type === 'edit' ? '编辑' : '查看';
      this.$nextTick(() => {
        this.$refs.form.allDisabled = type === 'edit' ? false : true;
      });
      getDetail(row.id).then((res) => {
        this.form = this._get(res, 'data.data', {});
        this.basicDataOption.group[0].display = this.form.parentId == 0 ? true : false;
      });
    },
    detailRowDel(row, index, done) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          return remove([row.id]);
        })
        .then((res) => {
          this.$refs.crud.refreshTable();
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
          done();
        });
    },
    weightCount(sum, weight, symbol) {
      let alen = String(sum).split('.')[1] || ''; // 算出每个小数的小数点长度
      let weightLength = String(weight).split('.')[1] || ''; // 算出每个小数的小数点长度
      let length = alen.length >= weightLength.length ? alen.length : weightLength.length;
      let pow = Math.pow(10, length);
      let result = symbol === '+' ? (sum * pow + weight * pow) / pow : (sum * pow - weight * pow) / pow;
      return result;
    }
  }
};
</script>

<style lang="scss" scoped>
.showDialog {
  ::v-deep .el-dialog__body {
    padding: 0px 20px;
  }
}
</style>
